#encoding=gb2312
import sys
import os

g_deleteFilePath="";
g_BinPath="";
g_objDeleteSavePath="";

g_DeleteList=[];

def GetCurDir():
	return sys.path[0];

def Main():
        global g_deleteFilePath;
        global g_objectDirPath;
        global g_objDeleteSavePath;
        if len(sys.argv) != 4:
                print "arg Error";
                assert(False);
        g_deleteFilePath = sys.argv[1];
        g_BinPath = sys.argv[2];
        g_objDeleteSavePath = sys.argv[3];
        if not os.path.exists(g_deleteFilePath):
                print("delete list does not exsit");
                assert(False);

        if not os.path.exists(g_objDeleteSavePath):
                os.mkdir(g_objDeleteSavePath);

        fp = open(g_deleteFilePath,"r");
        for line in fp:
                fileGsoRealPath = g_BinPath + os.sep + line;
                
                fileGsoRealPath = os.path.splitext(fileGsoRealPath)[0] + ".gso";
                fileMaskRealPath = os.path.splitext(fileGsoRealPath)[0] + ".mask";

                fileDestGsoPath = g_objDeleteSavePath + os.sep + os.path.basename(fileGsoRealPath);
                fileDestMaskPath = g_objDeleteSavePath + os.sep + os.path.basename(fileMaskRealPath);
                
                if os.path.exists(fileGsoRealPath):
                        fp1 = open(fileDestGsoPath,"wb");
                        fp2 = open(fileGsoRealPath,"rb");
                        fp1.write(fp2.read());
                        fp1.close();
                        fp2.close();
                        os.remove(fileGsoRealPath);
                        print "delete %s Complete" %  os.path.basename(fileGsoRealPath);
                if os.path.exists(fileMaskRealPath):
                        fp1 = open(fileDestMaskPath,"wb");
                        fp2 = open(fileMaskRealPath,"rb");
                        fp1.write(fp2.read());
                        fp1.close();
                        fp2.close();
                        os.remove(fileMaskRealPath);
                        print "delete %s Complete" %  os.path.basename(fileMaskRealPath);
        fp.close();
                
        
                
                

if __name__ == '__main__':
        Main();

